import time
import datetime
import threading

class Robot(threading.Thread):
    def __init__(self, platform):
        super().__init__()
        self._platform = platform
        self._all_service = {}
    def addService(self, service):
        self._all_service[service.get_name()] = service
    def delete_service(self, service_name):
        self._all_service.remove(service_name)
    def list_services(self):
        ans = []
        for service in self._all_service:
            ans.append(service.get_name())
        return ans

class PassiveRobot(Robot):
    def __init__(self, platform):
        super().__init__(platform)
    def run(self):
        while(True):
            new_post = self._platform.listen_new_post()
            print(new_post)
            for service in self._all_service:
                service.serv(new_post)

class ActiveRobot(Robot):
    def __init__(self, platform):
        super().__init__(platform)
    def run(self):
        while(True):
            time.sleep(3600)
            for service in self._all_service:
                service.serv(datetime.datetime.now())

if __name__ == "__main__":
    pass